package com.xb.controller;

import com.xb.entity.Patient;
import com.xb.service.IPatientService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Controller
 * /api/patient
 */
@RestController
@RequestMapping("/api/patient")
public class PatientController
{
    @Autowired
    private IPatientService patientService;

    @RequestMapping("/page")
    @RequiresPermissions("system:patient:page")
    public Object findPage(Patient obj, @RequestParam(value = "page",defaultValue = "1")Integer page,
                           @RequestParam(value = "limit",defaultValue = "10")Integer limit) {
        return patientService.selectPatientList(obj, page, limit);
    }

    /**
     * 添加
     */
    @PostMapping
    @RequiresPermissions("system:patient:add")
    public Object add(@RequestBody Patient obj) {
        return patientService.add(obj);
    }

    /**
     * 修改
     */
    @PutMapping
    @RequiresPermissions("system:patient:update")
    public Object update(@RequestBody Patient obj) {
        return patientService.update(obj);
    }
    /**
     * 删除
     */
    @DeleteMapping("/{id}")
    @RequiresPermissions("system:patient:del")
    public Object del(@PathVariable Integer id) {
        System.out.println(id);
        return null;
    }

}
